home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / var / lib / dpkg / info / libssl0.9.8.postinst < prev    next >
Encoding:
Text File  |  2008-07-25  |  5.2 KB  |  180 lines

  1. #!/bin/bash
  2.  
  3. . /usr/share/debconf/confmodule
  4.  
  5. set -e
  6.  
  7. package_name()
  8. {
  9.     echo $(basename $0 .postinst)
  10. }
  11.  
  12. # element() is a helper function for file-rc:
  13. element() {
  14.     local element list IFS
  15.  
  16.     element="$1"
  17.  
  18.     [ "$2" = "in" ] && shift
  19.     list="$2"
  20.     [ "$list" = "-" ] && return 1
  21.     [ "$list" = "*" ] && return 0
  22.  
  23.     IFS=","
  24.     set -- $list
  25.     case $element in
  26.     "$1"|"$2"|"$3"|"$4"|"$5"|"$6"|"$7"|"$8"|"$9")
  27.         return 0
  28.     esac
  29.     return 1
  30. }
  31.  
  32. # filerc (runlevel, service) returns /etc/init.d/service, if service is
  33. # running in $runlevel:
  34. filerc() {
  35.     local runlevel basename
  36.     runlevel=$1
  37.     basename=$2
  38.     while read LINE
  39.     do
  40.     case $LINE in
  41.         \#*|"") continue
  42.     esac
  43.  
  44.     set -- $LINE
  45.     SORT_NO="$1"; STOP="$2"; START="$3"; CMD="$4"
  46.     [ "$CMD" = "/etc/init.d/$basename" ] || continue
  47.  
  48.     if element "$runlevel" in "$START" || element "S" in "$START"
  49.     then
  50.         echo "/etc/init.d/$basename"
  51.         return 0
  52.     fi
  53.     done < /etc/runlevel.conf
  54.     echo ""
  55. }
  56.  
  57. if [ "$1" = "configure" ]
  58. then
  59.     if [ ! -z "$2" ]; then
  60.     if dpkg --compare-versions "$2" lt 0.9.8g-9; then
  61.         db_version 2.0
  62.  
  63.         echo -n "Checking for services that may need to be restarted..."
  64.  
  65.         check="sendmail openssh-server"
  66.         check="$check apache2-common ssh-nonfree exim4"
  67.         check="$check apache-ssl libapache-mod-ssl openvpn spamassassin"
  68.         check="$check courier-imap-ssl courier-mta-ssl courier-pop-ssl"
  69.         check="$check postfix cyrus21-imapd cyrus21-pop3d"
  70.         check="$check postgresql-7.4 postgresql-8.0 postgresql-8.1"
  71.         check="$check postgresql-8.2"
  72.         check="$check racoon dovecot-common bind9"
  73.         check="$check ntp openntpd clamcour nagios-nrpe-server"
  74.         check="$check clamav-freshclam clamav-daemon"
  75.         check="$check fetchmail ftpd-ssl slapd"
  76.         check="$check proftpd proftpd-ldap proftpd-mysql proftpd-pgsql"
  77.         check="$check partimage-server conserver-server tor"
  78.         # Only get the ones that are installed, and configured
  79.         check=$(dpkg -s $check 2> /dev/null | egrep '^Package:|^Status:' | awk '{if ($1 ~ /^Package:/) { package=$2 } else if ($0 ~ /^Status: .* installed$/) { print package }}')
  80.         # apache2 ships its init script in apache2-common, but the
  81.         # script is apache2
  82.         check=$(echo $check | sed 's/apache2-common/apache2/g')
  83.         # For mod-ssl apache has to be restarted
  84.         check=$(echo $check | sed 's/libapache-mod-ssl/apache/g')
  85.         # The name of proftpd-{ldap,mysql,pgsql} init script is
  86.         # same as "proftpd".
  87.         check=$(echo $check | sed 's/proftpd-.*/proftpd/g')
  88.             # dovecot-common ships its init script, but the
  89.         # script name is dovecot for dovecot-{imapd,pop3d}.
  90.         check=$(echo $check | sed 's/dovecot-common/dovecot/g')
  91.         # openssh-server's init script it called ssh
  92.         check=$(echo $check | sed 's/openssh-server/ssh/g')
  93.         echo "done."
  94.  
  95.         echo "Checking init scripts..."
  96.         for service in $check; do
  97.         if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
  98.            idl=$(ls /etc/init.d/${service} 2> /dev/null | head -n 1)
  99.            if [ -n "$idl" ] && [ -x $idl ]; then
  100.             services="$service $services"
  101.            else
  102.             echo "WARNING: init script for $service not found."
  103.            fi
  104.         else
  105.             if [ -f /usr/share/file-rc/rc ] || [ -f /usr/lib/file-rc/rc ] && [ -f /etc/runlevel.conf ]; then
  106.  
  107.             idl=$(filerc $rl $service)
  108.             else
  109.             idl=$(ls /etc/rc${rl}.d/S??${service} 2> /dev/null | head -n 1)
  110.             fi
  111.             if [ -n "$idl" ] && [ -x $idl ]; then
  112.                 services="$service $services"
  113.             fi
  114.         fi
  115.         done
  116.         if [ -n "$services" ]; then
  117.         db_reset libssl0.9.8/restart-services
  118.         db_set libssl0.9.8/restart-services "$services"
  119.         if [ "$RELEASE_UPGRADE_MODE" = desktop ]; then
  120.             db_input medium libssl0.9.8/restart-services || true
  121.         else
  122.             db_input critical libssl0.9.8/restart-services || true
  123.         fi
  124.         db_go || true
  125.         db_get libssl0.9.8/restart-services
  126.         
  127.         if [ "x$RET" != "x" ]
  128.         then
  129.             services=$RET
  130.             answer=yes
  131.         else
  132.             answer=no
  133.         fi
  134.         echo
  135.         if [ "$answer" = yes ] && [ "$services" != "" ]; then
  136.             echo "Restarting services possibly affected by the upgrade:"
  137.             failed=""
  138.             rl=$(runlevel | sed 's/.*\ //')
  139.             for service in $services; do
  140.             if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
  141.                 idl="invoke-rc.d ${service}"
  142.             elif [ -f /usr/share/file-rc/rc ] || [ -f /usr/lib/file-rc/rc ] && [ -f /etc/runlevel.conf ]; then
  143.                 idl=$(filerc $rl $service)
  144.             else
  145.                 idl=$(ls /etc/rc${rl}.d/S??${service} 2> /dev/null | head -n 1)
  146.             fi
  147.  
  148.             if ! $idl restart; then
  149.                 failed="$service $failed"
  150.             fi
  151.             done
  152.             echo
  153.             if [ -n "$failed" ]; then
  154.             db_subst libssl0.9.8/restart-failed services "$failed"
  155.             db_input critical libssl0.9.8/restart-failed || true
  156.             db_go || true
  157.             else
  158.             echo "Services restarted successfully."
  159.             fi
  160.             echo
  161.         fi
  162.         else
  163.         echo "Nothing to restart."
  164.         fi
  165.         # Shut down the frontend, to make sure none of the
  166.         # restarted services keep a connection open to it
  167.         db_stop
  168.     fi # end upgrading and $2 lt 0.9.8c-2
  169.     fi # Upgrading
  170.  
  171.     [ -x /usr/share/update-notifier/notify-reboot-required ] && /usr/share/update-notifier/notify-reboot-required
  172. fi
  173.  
  174. # Automatically added by dh_makeshlibs
  175. if [ "$1" = "configure" ]; then
  176.     ldconfig
  177. fi
  178. # End automatically added section
  179.  
  180.